The Task

In this blog post we will explore and understand malaria with three informative visualizations. The malaria data came from this github: https://github.com/rfordatascience/tidytuesday/tree/master/data/2018/2018-11-13.

Plotly

I chose to use plotly for my visualizations because it was easily integrated into Jupyter notebook. Plotly allows you to easily create interactive visualizations using python. I found it to be straightforward and easily customizable.

import plotly.io as pio
pio.renderers.default='notebook_connected'
# Inject the missing require.js dependency.
from IPython.display import display, HTML
js = '<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" integrity="sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==" crossorigin="anonymous"></script>'
display(HTML(js))

Load Data

import pandas as pd
import plotly.express as px
from IPython.display import HTML

import pandas as pd
import plotly
import plotly.express as px
from IPython.display import display_html, HTML
from io import StringIO
df_inc = pd.read_csv('malaria_inc.csv')
df_deaths = pd.read_csv('malaria_deaths.csv')
df_deaths_age = pd.read_csv('malaria_deaths_age.csv')
#Make df for values within income vars
income_set = ['Early-demographic dividend','Low & middle income','Low income','Lower middle income','Middle income','Upper Middle Income']
df_inc_only = df_inc[df_inc['Entity'].isin(income_set)]

Malaria Cases By Country

This first visualization shows how many cases of malaria are occurring per 1,000 people in countries around the world from 2000 - 2015. We see that the countries with the most cases of malaria are concentrated in Africa, South America, and Southeast Asia. Especially in Africa, almost all countries are experiencing 12 cases per 1,000 population. We also notice that some countries have reduced their case numbers from 2000 to 2015.

fig = px.choropleth(df_inc, locations='Code', color='Incidence of malaria (per 1,000 population at risk) (per 1,000 population at risk)',
                           color_continuous_scale="blues",
                           range_color=(0, 12),
                           scope="world",
                           labels={'Incidence of malaria (per 1,000 population at risk) (per 1,000 population at risk)':'Cases per 1,000'},
                            title="Malaria Cases By Country",
                    animation_frame="Year"
                          )
fig.update_geos(projection_type="natural earth")
#HTML(fig.to_html(include_plotlyjs='cdn'))
#fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
#HTML(fig.to_html(include_plotlyjs='cdn'))
#HTML(fig.to_html())
HTML(fig.to_html(include_plotlyjs='cdn'))